using System;
using System.Collections.Generic;
using System.ByteBuffer;
using tools;

namespace thirteen
{
    /// <summary>
    /// generate by msg tool
    /// 游戏局结束
    /// </summary>
	public class ResRoundOverMsg : ResMessage
	{
		//局结算明细信息
		public List<RoundPlayerBillInfo> items = new List<RoundPlayerBillInfo>();
		
		//是否打枪(0:不上,非0:是)
		public int isShoot;
		//打枪结算明细信息(没有打枪就不发)
		public List<ShootInfo> shootInfo = new List<ShootInfo>();
		
		//是否全垒打(0:不上,非0:是)
		public int isAllShoot;
		//全垒打玩家id(没有全垒打不发)
		public long allShootId;

        public ResRoundOverMsg() { }

        public ResRoundOverMsg(int isShoot, int isAllShoot, long allShootId)
        {
            this.isShoot = isShoot;
            this.isAllShoot = isAllShoot;
            this.allShootId = allShootId;
        }

        
		public void write(object obj)
		{
            ByteBuffer b = obj as ByteBuffer;
			b.PushInt(items.Count);

			foreach (var element in items)
			{
				element.write(b);
			}
			b.PushInt(isShoot);
			b.PushInt(shootInfo.Count);

			foreach (var element in shootInfo)
			{
				element.write(b);
			}
			b.PushInt(isAllShoot);
			b.PushLong(allShootId);
			
		}

	    public void read(object obj)
		{
            MyConverter b = obj as MyConverter;
			int items_length = b.toInt32();
			for (int i = 0; i < items_length; ++i)
			{
				var dto = new RoundPlayerBillInfo();
				dto.read(b);
				items.Add(dto);
			}
			isShoot = b.toInt32();
			int shootInfo_length = b.toInt32();
			for (int i = 0; i < shootInfo_length; ++i)
			{
				var dto = new ShootInfo();
				dto.read(b);
				shootInfo.Add(dto);
			}
			isAllShoot = b.toInt32();
			allShootId = b.toInt64();
			
		}

		public int Id
		{
            get { return 621231; }
		}

        public String Desc
        {
            get { return "游戏局结束"; }
        }
	}
}